"""Python script to read settings from xml files in the settings directory"""

import xml.etree.ElementTree as ElementTree

settingslist = {"doc_color1": "#CCCCCC", "doc_color2": "#DDDDDD", "doc_columns": "2"}


def readsettings():
    """Function extracting variable values from xml files"""
    doc_tree = ElementTree.parse("settings/doc_settings.xml")
    doc_root = doc_tree.getroot()
    for child in doc_root:
        settingslist["doc_{varname}".format(varname=child.tag)] = child.text

    text_tree = ElementTree.parse("settings/text_settings.xml")
    text_root = text_tree.getroot()
    for child in text_root:
        settingslist["text_{varname}".format(varname=child.tag)] = child.text

    col1_tree = ElementTree.parse("settings/col1_settings.xml")
    col1_root = col1_tree.getroot()
    for child in col1_root:
        settingslist["col1_{varname}".format(varname=child.tag)] = child.text

    col2_tree = ElementTree.parse("settings/col2_settings.xml")
    col2_root = col2_tree.getroot()
    for child in col2_root:
        settingslist["col2_{varname}".format(varname=child.tag)] = child.text


def printsettings():
    """Prints the contents of the settings dict"""
    for k, v in settingslist.items():
        print("{varname} = {varval}".format(varname=k, varval=v))